#include "BasicJNI.h"
#include "BasicFunctionAPI.h"
#include <string>

namespace utility
{
	/*BasicJNI::BasicJNI(void)
	{
	}

	BasicJNI::~BasicJNI(void)
	{
	}*/

	std::string jstringTostring(JNIEnv* env, jstring jstr)
	{   
		char*   rtn   =   NULL;   
		jclass   clsstring   =   env->FindClass("java/lang/String");   
		jstring   strencode   =   env->NewStringUTF("GB2312");   
		jmethodID   mid   =   env->GetMethodID(clsstring,   "getBytes",   "(Ljava/lang/String;)[B");   
		jbyteArray   barr=   (jbyteArray)env->CallObjectMethod(jstr,mid,strencode);   
		jsize   alen   =   env->GetArrayLength(barr);   
		jbyte*   ba   =   env->GetByteArrayElements(barr,JNI_FALSE);   
		if(alen   >   0)   
		{   
			rtn   =   (char*)malloc(alen+1);         
			memcpy(rtn,ba,alen);   
			rtn[alen]=0;   
		}   
		env->ReleaseByteArrayElements(barr,ba,0);   
		std::string stemp(rtn);
		free(rtn);
		return   stemp;   
	}   

#ifdef __cplusplus
	extern "C" {
#endif

	JNIEXPORT void JNICALL Java_BasicJNI_BasicJNIZeroParamNoRetApi( JNIEnv *env, jobject, jobject object, jstring jstrDll, jstring jstrFuncName, ... )
	{
		std::string strDll = jstringTostring(env, jstrDll);
		std::string strFuncName = jstringTostring(env, jstrFuncName);
	}


#ifdef __cplusplus
	}
#endif
}
